<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="#0A5AF9">
    <title>车车侠</title>
    <link rel="stylesheet" type="text/css" href="../css/public-head.css" />
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
    <link rel="stylesheet" href="../css/homePage.css">
</head>

<body>
    <div class="background">
        <img src="../image/homepage/beijing.png">
    </div>
    <div class="main caontain">
        <div id="isLogin">
            <div class="banner" onclick="Login()" tapmode>
                <div class="login">登录</div>
            </div>
        </div>
        <div class="main-action">
            <div class="state">
                <div>
                    <div tapmode onclick="MyOrder(0)">
                        <div class="y1"><img src="../image/homepage/dingd-yxd.png" alt="" />
                            <!-- <div><div>2</div></div> -->
                        </div>
                        <div>已下单</div>
                    </div>
                    <div tapmode onclick="MyOrder(2)">
                        <div class="y2"><img src="../image/homepage/dingd-dwc.png" alt="" />
                            <!-- <div><div>8</div></div> -->
                        </div>
                        <div>待评价</div>
                    </div>
                    <div tapmode onclick="Coupon()">
                        <div class="y3"><img src="../image/homepage/dingd-yhq.png" alt="" />
                            <!-- <div><div>6</div></div> -->
                        </div>
                        <div>优惠券</div>
                    </div>
                    <div>
                        <div class="y4"><img src="../image/homepage/dingd-cljc.png" alt="" />
                            <!-- <div><div>2</div></div> -->
                        </div>
                        <div>车辆检测</div>
                    </div>
                </div>
                <div>
                    <div>状态<a href="">通知</a></div>
                    <div></div>
                    <div class="state-h">
                        <marquee loop="-1" scrollamount="3">还没为您的爱车进行养护吗？<span>赶快下单吧~</span></marquee>

                        <!-- <marquee loop="-1" scrollamount="3">正在为您的爱车服务，<span>请耐心等待~</span></marquee> -->
                    </div>
                </div>
            </div>
            <!--中间6个图标-->
            <div class="function">
                <div>
                    <div tapmode onclick="orderdetails_1(2)">
                        <div>
                            <img src="../image/homepage/sy-yjxc.png" alt="" />
                        </div>
                        <div>一键洗车</div>
                    </div>
                    <div tapmode onclick="orderdetails_1(1)">
                        <div>
                            <img src="../image/homepage/sy-mrby.png" alt="" />
                        </div>
                        <div>美容保养</div>
                    </div>
                </div>
                <div>
                    <div onclick="TooilCard()">
                        <div>
                            <img src="../image/homepage/sy-ykcz.png" alt="" />
                        </div>
                        <div>油卡充值</div>
                    </div>
                    <div>
                        <div>
                            <img src="../image/homepage/sy-yycd.png" alt="" />
                        </div>
                        <div>预约充电</div>
                    </div>
                </div>
                <div>
                    <div onclick="goNew()">
                        <div>
                            <img src="../image/homepage/sy-wxgz.png" alt="" />
                        </div>
                        <div>维修改装</div>
                    </div>
                    <div>
                        <div>
                            <img src="../image/homepage/sy-bjpq.png" alt="" />
                        </div>
                        <div>钣金喷漆</div>
                    </div>
                </div>
            </div>
            <!--优惠活动-->
            <div class="activity">
                <div>
                    <div>
                        <div></div>
                        <div>优惠活动</div>
                    </div>
                    <div>
                        <div>
                            <img src="../image/homepage/youfanhui.png" alt="" />
                        </div>
                    </div>
                </div>
                <!--优惠券-->
                <div class="swiper-container">
                    <div class="swiper-wrapper" onclick="Tovip()">
                        <div class="swiper-slide"><img src="../image/homepage/hdye-1.png" alt="" /></div>
                        <div class="swiper-slide"><img src="../image/homepage/hdye-1.png" alt="" /></div>
                        <div class="swiper-slide"><img src="../image/homepage/hdye-1.png" alt="" /></div>
                        <div class="swiper-slide"><img src="../image/homepage/hdye-1.png" alt="" /></div>
                        <div class="swiper-slide"><img src="../image/homepage/hdye-1.png" alt="" /></div>
                    </div>
                    <!-- Add Pagination -->
                    <div class="swiper-pagination"></div>
                </div>

            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/public-head.js"></script>
<script type="text/javascript" src="../script/swiper.min.js"></script>
<script type="text/javascript" src="../script/rem.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/mui.js"></script>
<script type="text/javascript" src="../script/template-web.js"></script>
<script type="text/javascript" src="../script/md5.js"></script>
<script type="text/html" id="loginTemp">
    {{if isLogin
    <0}} <div class="banner" onclick="Login()" tapmode>
        <div class="login">登录</div>
        </div>
        {{else}}
        <div class="banner" tapmode onclick="Main_Frame_two()">
            <div>
                <div>
                    <div>
                        {{if isLogin.avatar==null}}
                        <img src="../image/icon/touxiang@2x.png" alt="" /> {{else}}
                        <img src="{{isLogin.avatar}}" alt="" class="avatar"> {{/if}}

                    </div>
                </div>
                <div>
                    <div>{{isLogin.showTime}}{{isLogin.nickname}}</div>
                    <div>{{isLogin.car_number}}</div>
                    <div>洗车指数：
                        <!-- <span><img src="../image/icon/xx-hs@2x.png" alt="" /></span> -->
                        <!-- <span><img src="../image/icon/xx-hs@2x.png" alt="" /></span>
                        <span><img src="../image/icon/xx-hs@2x.png" alt="" /></span>
                        <span><img src="../image/icon/xx-hs@2x.png" alt="" /></span>
                        <span><img src="../image/icon/xx-hs@2x.png" alt="" /></span> -->
                        <!-- <span><img src="../image/icon/xx-bhs@2x.png" alt="" /></span> -->
                        <span><img src="../image/homepage/xx-xg.png" alt="" /></span>
                        <span><img src="../image/homepage/xx-xg.png" alt="" /></span>
                        <span><img src="../image/homepage/xx-xg.png" alt="" /></span>
                        <span><img src="../image/homepage/xx-xg.png" alt="" /></span>
                        <span><img src="../image/homepage/xx-xg.png" alt="" /></span>
                    </div>
                </div>
            </div>
        </div>
        {{/if}}
</script>

<script type="text/javascript">
    var showTime;
    console.log("USERTOKEN: " + token);
    apiready = function() {
        fnGetInfo()
        init()
            // fnGetLoginData()
        bindingInformation()
    }

    headInner({
        title: "车车侠",
        //headleft
        headl: '<div class="tu_1"><img src="../image/icon/dw-bs@2x.png" alt=""/></div><div class="didian">南宁</div>',
        //headright
        headr: '<div class="tu_2" tapmode onclick="Being()"><img src="../image/icon/xx-bs@2x.png" alt=""  /></div>',
        color: "transparent", //默认是蓝色
        padding: "0 0 0", //默认有padding:45px 15px 0;
    })


    //图片左滑右滑
    var swiper = new Swiper('.swiper-container', {
        spaceBetween: 5,
        pagination: '.swiper-pagination',
        paginationClickable: true,
        freeModeMomentum: false,
        freeMode: true,
        slidesPerView: 1.2,
        autoplay: true,
    });

    function oilCard() {
        api.openWin({
            name: 'oilCard',
            url: '../html/oilCard.html'
        });
    }
    //goNew
    function goNew(){
      console.log("99999999999");
      api.openWin({
          name: 'demo1',
          url: '../html/demo1.html'
      });
    }
    // 获取登录信息
    function fnGetLoginData() {
        fnshowTime()
        var data = $api.getStorage('UserBase');
        if (data) {
            data.showTime = showTime;
        }
        console.log('我的信息:');
        console.table(JSON.stringify(data));
        // 添加点击屏幕监听
        api.addEventListener({
            name: 'tap'
        }, function(ret, err) {
            // alert('点击了页面');
            if (!data) {
                Login()
            } else {
                console.log('点击了页面');
            }
        });

        var obj = {
            'isLogin': data
        }
        var html = template('loginTemp', obj);
        document.getElementById('isLogin').innerHTML = html; //绑定ID  渲染
    }

    // 绑定推送的别名
    function bindingInformation() {
        var ajpush = api.require('ajpush');
        var res = $api.getStorage('UserBase');
        if (res.mobile) {
            var param = {
                alias: md5('ccx2019' + res.mobile + 'phone')
            };
            ajpush.bindAliasAndTags(param, function(ret) {
                var statusCode = ret.statusCode;
                if (statusCode == "0") {
                    console.log("绑定: " + statusCode);
                    // alert('綁定狀態：' + statusCode)
                }
            });
        }
    }


    function Login() {
        api.openWin({
            name: 'Login',
            url: 'Login.html',
            bounces: false,
            opaque: false,
            showProgress: true,
            vScrollBarEnabled: false,
            hScrollBarEnabled: false,
            slidBackEnabled: false,
            delay: 1000,
            animation: {
                type: 'ripple',
                duration: 1000
            }
        });
    }

    function fnshowTime() {
        var now = new Date();
        var hour = now.getHours();
        if (hour < 6) {
            showTime = "凌晨好！"
        } else if (hour < 9) {
            showTime = "早上好！"
        } else if (hour < 12) {
            showTime = "上午好！"
        } else if (hour < 14) {
            showTime = "中午好！"
        } else if (hour < 17) {
            showTime = "下午好！"
        } else if (hour < 19) {
            showTime = "傍晚好！"
        } else if (hour < 22) {
            showTime = "晚上好！"
        } else {
            showTime = "夜里好！"
        }
    }

    // 优惠活动
    function Tovip() {
        api.openWin({
            name: 'SetMeal',
            url: '../html/SetMeal.html'
        });

    }

    function TooilCard() {
      api.openWin({
          name: 'oilCard',
          url: '../html/oilCard.html',
      });

    }

    /*function MessageCenter() {
        api.openWin({
            name: 'MessageCenter',
            url: '../html/MessageCenter.html'
        });
    }*/

    function Main_Frame_two() {
        api.openWin({
            name: 'Main_Frame_two',
            url: '../html/Main_Frame_two.html'
        });
    }

    function MyOrder(index_) {
        api.openWin({
            name: 'MyOrder',
            url: '../html/MyOrder.html',
            pageParam: {
                active_index: index_
            }
        });
    }

    function Coupon() {
        api.openWin({
            name: 'Coupon',
            url: '../html/Coupon.html'
        });
    }

    function orderdetails_1(i) {
        api.openWin({
            name: 'order-details_1',
            url: '../html/order-details_1.html',
            pageParam: {
                pid: i
            }
        });
    }

    function MessageCenter() {
        api.openWin({
            name: 'MessageCenter',
            url: '../html/MessageCenter.html'
        });
    }
    //正在开发中
    function Being() {
        api.toast({
            msg: '敬请期待~',
            duration: 2000,
            location: 'bottom'
        });
    }


    // 获取个人信息
    function fnGetInfo() {
        BASE.MYajax({
            'pathName': 'users/getUserInfo',
            'method': initInfo
        });
    }

    function initInfo(ret, err) {
        if (ret.code == 200) {
            //设置全局变量
            $api.setStorage('UserBase', ret.data);
            fnGetLoginData()
            console.log("调用主页成功");
        }
    }
</script>

</html>
